<?php
/**
 * @link https://ym2.cleverstone.top
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

namespace common\helper;

use Yii;

/**
 * Http助手
 * @author cleverstone
 * @since ym2.0
 */
class Http extends \builder\helper\Http
{
    /**
     * 获取客户端系统
     * @return string
     */
    public static function getClientOs()
    {
        $request = Yii::$app->request;
        $userAgent = $request->userAgent;
        if (preg_match('/windows/i', $userAgent)) {
            $os = 'Windows';
        } elseif (preg_match('/iphone/i', $userAgent)) {
            $os = 'iPhone';
        } elseif (preg_match('/ipad/i', $userAgent)) {
            $os = 'iPad';
        } elseif (preg_match('/android/i', $userAgent)) {
            $os = 'Android';
        } else {
            $os = 'Linux';
        }

        return $os;
    }
}